
#ifdef a
#include<stdio.h>

//直接插入排序(降序)
void InserSort(int* arr, int size) {
	for (int i = 1; i < size; i++) {
		int end = i - 1;
		int key = arr[i];
		while(end >= 0 && arr[end] < key){
			arr[end + 1] = arr[end];
			end--;
		}
		arr[end + 1] = key;
	}
	return;
}
//稳定性：排序时不包括等于号--》稳定排序
void InsertPrint(int* arr, int size) {
	for (int i = 0; i < size; i++)
		printf("%d ", arr[i]);
	printf("\n");
	return;
}
//插入排序->直接插入排序
int main() {
	int arr[] = { 1,2,3,4,5,6,7,8,9,10 };
	int size = sizeof(arr) / sizeof(arr[0]);
	InserSort(arr, size);
	InsertPrint(arr, size);
}
#endif 